<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<!-- Meta, title, CSS, favicons, etc. -->
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">

<title>随便打TCS系统</title>

<!-- Bootstrap -->
<link href="<%=basePath%>vendors/bootstrap/dist/css/bootstrap.min.css"
	rel="stylesheet">
<!-- Font Awesome -->
<link
	href="//netdna.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css"
	rel="stylesheet">
<!-- Select2 -->
<link href="<%=basePath%>vendors/select2/dist/css/select2.min.css"
	rel="stylesheet">
<!-- NProgress -->
<link href="<%=basePath%>vendors/nprogress/nprogress.css"
	rel="stylesheet">
<!-- iCheck -->
<link href="<%=basePath%>vendors/iCheck/skins/flat/green.css"
	rel="stylesheet">

<!-- bootstrap-progressbar -->
<link
	href="<%=basePath%>vendors/bootstrap-progressbar/css/bootstrap-progressbar-3.3.4.min.css"
	rel="stylesheet">
<!-- JQVMap -->
<link href="<%=basePath%>vendors/jqvmap/dist/jqvmap.min.css"
	rel="stylesheet" />
<!-- bootstrap-daterangepicker -->
<link
	href="<%=basePath%>vendors/bootstrap-daterangepicker/daterangepicker.css"
	rel="stylesheet">

<!-- Custom Theme Style -->
<link href="<%=basePath%>build/css/custom.min.css" rel="stylesheet">
</head>

<body class="nav-md">
	<div class="container body">
		<div class="main_container">
			<div class="col-md-3 left_col">
				<div class="left_col scroll-view">


					<div class="clearfix"></div>

					<br />


				</div>
			</div>



			<!-- page content -->
			<div class="right_col" role="main">
				<div class="">
					<div class="page-title">
						<div class="title_left">
							<h3>创建一个新的账户</h3>
						</div>


					</div>
					<div class="clearfix"></div>

					<div class="row">
						<div class="col-md-12 col-sm-12 col-xs-12">
							<div class="x_panel">
								<div class="x_title">
									<h2>添加账户信息</h2>

									<div class="clearfix"></div>
								</div>
								<div class="x_content">

									<form name="myForm" class="form-horizontal form-label-left"
										novalidate method="post" enctype="multipart/form-data"
										id="formUpload">

										<p>
											您需要将以下内容填写完整后才可以创建商家，如有疑问请
											<code>联系客服</code>
											以帮助您完成相关配置以及信息完善
										</p>
										<span class="section">基本信息</span>

										<div class="item form-group">
											<label class="control-label col-md-3 col-sm-3 col-xs-12"
												for="name">账户名 <span class="required">*</span>
											</label>
											<div class="col-md-6 col-sm-6 col-xs-12">
												<input id="username" class="form-control col-md-7 col-xs-12"
													name="name" placeholder="例如：${user.username}" required="required"
													type="text">
											</div>
										</div>

										<div class="item form-group">
											<label class="control-label col-md-3 col-sm-3 col-xs-12"
												for="name">登陆密码 <span class="required">*</span>
											</label>
											<div class="col-md-6 col-sm-6 col-xs-12">
												<input id="password" class="form-control col-md-7 col-xs-12"
													name="name" placeholder="例如：字母或者数字" required="required"
													type="text">
											</div>
										</div>

										<div class="item form-group">
											<label class="control-label col-md-3 col-sm-3 col-xs-12"
												for="name">费率 <span class="required">*</span>
											</label>
											<div class="col-md-6 col-sm-6 col-xs-12">
												<select class="form-control" id="freeroute">
													<c:forEach items="${freeroutes}" var="s" varStatus="z">
														<option value="${s.name}">${s.name}</option>
													</c:forEach>
												</select>
											</div>
										</div>
										<div class="item form-group">
											<label class="control-label col-md-3 col-sm-3 col-xs-12"
												for="name">在线支付 <span class="required">*</span>
											</label>
											<div class="col-md-6 col-sm-6 col-xs-12" id="isalipay">
												<select class="form-control">
													<option value="true" selected="selected">允许</option>
													<option value="false">不允许</option>
												</select>
											</div>
										</div>

										<div class="item form-group">
											<label class="control-label col-md-3 col-sm-3 col-xs-12"
												for="name">开设下级商户 <span class="required">*</span>
											</label>
											<div class="col-md-6 col-sm-6 col-xs-12">
												<select class="form-control" id="nextagent">
													<option value="true" selected="selected">允许</option>
													<option value="false">不允许</option>
												</select>
											</div>
										</div>
										<div class="item form-group">
											<label class="control-label col-md-3 col-sm-3 col-xs-12"
												for="name">空中充值权限 <span class="required">*</span>
											</label>
											<div class="col-md-6 col-sm-6 col-xs-12">
												<select class="form-control" id="airrecharge">
													<option value="1" selected="selected">允许</option>
													<option value="0">不允许</option>
												</select>
											</div>
										</div>
										<div class="item form-group">
											<label class="control-label col-md-3 col-sm-3 col-xs-12"
												for="name">开卡权限 <span class="required">*</span>
											</label>
											<div class="col-md-6 col-sm-6 col-xs-12">
												<select class="form-control" id="addcard">
													<option value="true" selected="selected">允许</option>
													<option value="false">不允许</option>
												</select>
											</div>
										</div>

										<div class="item form-group">
											<label class="control-label col-md-3 col-sm-3 col-xs-12"
												for="name">LOGO <span class="required">*</span>
											</label>
											<div class="col-md-6 col-sm-6 col-xs-12">
												<input class="form-control col-md-7 col-xs-12" id="file"
													name="file" required="required" type="file"
													placeholder="请先上传图片" form="formUpload">
											</div>
										</div>

										<div class="item form-group">
											<label class="control-label col-md-3 col-sm-3 col-xs-12"
												for="name">通话引擎<span class="required">*</span>
											</label>
											<div class="col-md-6 col-sm-6 col-xs-12">
												<select class="form-control" id="calltype" onchange="show(this)">
													<option value="1" selected="selected">SBDJH引擎</option>
													<option value="2">SBDMY引擎</option>
													<option value="3">SBDZP引擎</option>
													<option value="4">SBDST引擎</option>
													<option value="5">SBDCP引擎</option>
													<option value="6">XGJCP引擎</option>
													<option value="7">BCJH引擎</option>
													<option value="8">XGJZP引擎</option>
													<option value="9">SBDJHOLD引擎</option>
													<option value="10">SBDJHCUSTOM引擎</option>
													<option value="11">SBDSC引擎</option>
												</select>
											</div>
										</div>

										<div class="item form-group" id="jhid" style="display: none">
											<label class="control-label col-md-3 col-sm-3 col-xs-12"
												   for="name">JHAPP用户名 <span class="required">*</span>
											</label>
											<div class="col-md-6 col-sm-6 col-xs-12">
												<input id="jhappid" class="form-control col-md-7 col-xs-12"
													   name="jhappid" placeholder="例如：张三" required="required"
													   type="text">
											</div>
										</div>
										<div class="item form-group" id="jhkey" style="display: none">
											<label class="control-label col-md-3 col-sm-3 col-xs-12"
												   for="name">JHAPP密码 <span class="required">*</span>
											</label>
											<div class="col-md-6 col-sm-6 col-xs-12">
												<input id="jhappkey" class="form-control col-md-7 col-xs-12"
													   name="jhappkey" placeholder="例如：张三" required="required"
													   type="text">
											</div>
										</div>

										<div class="item form-group">
											<label class="control-label col-md-3 col-sm-3 col-xs-12"
												for="name">负责人 <span class="required">*</span>
											</label>
											<div class="col-md-6 col-sm-6 col-xs-12">
												<input id="email" class="form-control col-md-7 col-xs-12"
													name="name" placeholder="例如：张三" required="required"
													type="text">
											</div>
										</div>

										<div class="item form-group">
											<label class="control-label col-md-3 col-sm-3 col-xs-12"
												for="name">ADID <span class="required">*</span>
											</label>
											<div class="col-md-6 col-sm-6 col-xs-12">
												<input id="adid" class="form-control col-md-7 col-xs-12"
													name="name" placeholder="例如：145910000" required="required"
													type="text">
											</div>
										</div>
										<div class="item form-group">
											<label class="control-label col-md-3 col-sm-3 col-xs-12"
												for="name">PID <span class="required">*</span>
											</label>
											<div class="col-md-6 col-sm-6 col-xs-12">
												<input id="pid" class="form-control col-md-7 col-xs-12"
													name="name"
													placeholder="例如：mm_101082177_39184040_145910000"
													required="required" type="text">
											</div>
										</div>
										<div class="item form-group">
											<label class="control-label col-md-3 col-sm-3 col-xs-12"
												for="name">短信签名ID<span class="required">*</span>
											</label>
											<div class="col-md-6 col-sm-6 col-xs-12">
												<input id="signid" class="form-control col-md-7 col-xs-12"
													name="signid" required="required" type="text">
											</div>
										</div>

										<div class="item form-group">
											<label class="control-label col-md-3 col-sm-3 col-xs-12"
												for="name">淘宝授权 </label><span class="required">*</span>
											<div class="col-md-6 col-sm-6 col-xs-12">
												<input class="form-control col-md-7 col-xs-12" name="name"
													placeholder="" type="text" value="" id="sqappkey">
											</div>
										</div>

										<div class="item form-group">
											<label class="control-label col-md-3 col-sm-3 col-xs-12"
												for="name">需要分润<span class="required">*</span>
											</label>
											<div class="col-md-6 col-sm-6 col-xs-12">
												<select class="form-control" id="isprofit">
													<option value="true" selected="selected">允许</option>
													<option value="false">不允许</option>
												</select>
											</div>
										</div>

										<div class="item form-group">
											<label class="control-label col-md-3 col-sm-3 col-xs-12"
												for="name">分润比例 <span class="required">*</span>
											</label>
											<div class="col-md-6 col-sm-6 col-xs-12">
												<input id="dkbl" class="form-control col-md-7 col-xs-12"
													name="name" placeholder="例如：1.00" required="required"
													type="text">
											</div>
										</div>
										<div class="item form-group">
											<label class="control-label col-md-3 col-sm-3 col-xs-12"
												for="name">支付分润<span class="required">*</span>
											</label>
											<div class="col-md-6 col-sm-6 col-xs-12">
												<select class="form-control" id="isaliprofit">
													<option value="true" selected="selected">允许</option>
													<option value="false">不允许</option>
												</select>
											</div>
										</div>

										<div class="item form-group">
											<label class="control-label col-md-3 col-sm-3 col-xs-12"
												for="name">支付分润比例 <span class="required">*</span>
											</label>
											<div class="col-md-6 col-sm-6 col-xs-12">
												<input id="aliprofitratio"
													class="form-control col-md-7 col-xs-12" name="name"
													placeholder="例如：1.00" required="required" type="text">
											</div>
										</div>

										<div class="item form-group">
											<label class="control-label col-md-3 col-sm-3 col-xs-12"
												for="name">充值短信 <span class="required"></span>
											</label>
											<div class="col-md-6 col-sm-6 col-xs-12">
												<input id="count" class="form-control col-md-7 col-xs-12"
													name="name" placeholder="" required="required" type="text"
													value="">
											</div>
										</div>

										<div class="item form-group">
											<label class="control-label col-md-3 col-sm-3 col-xs-12"
												for="name">透支额度 <span class="required"></span>
											</label>
											<div class="col-md-6 col-sm-6 col-xs-12">
												<input id="overdraft"
													class="form-control col-md-7 col-xs-12" name="name"
													placeholder="" required="required" type="text" value="">
											</div>
										</div>

										<div class="item form-group">
											<label class="control-label col-md-3 col-sm-3 col-xs-12"
												for="name">注册赠送话费<span class="required"></span>
											</label>
											<div class="col-md-6 col-sm-6 col-xs-12">
												<input id="regimoney"
													class="form-control col-md-7 col-xs-12" name="name"
													placeholder="" required="required" type="text" value="">
											</div>
										</div>
										<div class="item form-group">
											<label class="control-label col-md-3 col-sm-3 col-xs-12"
												for="name">注册赠送购物金<span class="required"></span>
											</label>
											<div class="col-md-6 col-sm-6 col-xs-12">
												<input id="regishopmoney"
													class="form-control col-md-7 col-xs-12" name="name"
													placeholder="" required="required" type="text" value="">
											</div>
										</div>
										<div class="item form-group">
											<label class="control-label col-md-3 col-sm-3 col-xs-12"
												for="name">注册赠送有效期<span class="required"></span>
											</label>
											<div class="col-md-6 col-sm-6 col-xs-12">
												<input id="regitime"
													class="form-control col-md-7 col-xs-12" name="name"
													placeholder="例如：15(15等于15天)" 
													required="required" type="text" value="">
											</div>
											<span id="updateregitime" style="font-size: 14px;color:#ff0033;display: none">
											                如未填写，默认有效期为15天</span>
										</div>
										<div class="ln_solid"></div>
										<div class="form-group">
											<div class="col-md-6 col-md-offset-3">
												<a type="submit" class="btn btn-primary"
													href="javascript:void(0)"
													onclick="history.back(-1);">取消</a> <input
													id="add" type="button" class="btn btn-success"
													href="javascript:void(0)" value="添加">
											</div>
										</div>
									</form>
								</div>
							</div>
						</div>
					</div>
				</div>
			</div>
			<!-- /page content -->
			<!-- 上传图片并添加-->
			<script src="<%=basePath%>vendors/jquery/dist/jquery.min.js"></script>
			<script type="text/javascript">
				$('#add').click(function() {
			
					var file = document.myForm.file.files[0];
			
					if (file != null || file != undefined) {

				    	var fileName = file.name.substring(file.name.lastIndexOf(".")+1).toLowerCase();
						
						if(fileName !="jpg" && fileName !="jpeg" && fileName !="png"&& fileName !="gif" ){
							alert("只能上传.jpg  .png  .jpeg  .gif类型的文件!");
				            return;
						}

						
						
						var fm = new FormData();
			
						fm.append('file', file);
			
						$.ajax(
							{
								url : "<%=basePath%>layfile/uploadFile1",
								type : 'POST',
								data : fm,
								contentType : false, //禁止设置请求类型
								processData : false, //禁止jquery对DAta数据的处理,默认会处理
								//禁止的原因是,FormData已经帮我们做了处理
								success : function(result) {
									//测试是否成功
									//但需要你后端有返回值
									ajaxPost(result.json);
								}
							}
						);
					} else {
						ajaxPost(null);
					}
				});
			</script>
			<script>
				function show(obj){
					document.getElementById("jhid").style.display=(obj.value==10)?"":"none";
					document.getElementById("jhkey").style.display=(obj.value==10)?"":"none"
				}
			</script>
			<script type="text/javascript">
			$("#regitime").mouseover(function(){
			    $("#updateregitime").css("display","block");
			});
			$("#regitime").mouseout(function(){
				$("#updateregitime").css("display","none");
			});

				// ajax 对象
				function ajaxObject() {
					var xmlHttp;
					try {
						// Firefox, Opera 8.0+, Safari
						xmlHttp = new XMLHttpRequest();
					} catch (e) {
						// Internet Explorer
						try {
							xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
						} catch (e) {
							try {
								xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
							} catch (e) {
								alert("您的浏览器不支持AJAX！");
								return false;
							}
						}
					}
					return xmlHttp;
				}
			
				// ajax post请求：
				function ajaxPost(logo) {
					var username = $("#username").val();
					var password = $("#password").val();
					var pic = $("#pic").val();
					var adid = $("#adid").val();
					var pid = $("#pid").val();
					var email = $("#email").val();
					var dkbl = $("#dkbl").val();
					var freeroute = $("#freeroute").find("option:selected").val();
					var calltype = $("#calltype").find("option:selected").val();
					var isalipay = $("#isalipay").find("option:selected").val();
					var nextagent = $("#nextagent").find("option:selected").val();
					var airrecharge = $("#airrecharge").find("option:selected").val();
					var isprofit = $("#isprofit").find("option:selected").val();
					var isaliprofit = $("#isaliprofit").find("option:selected").val();
					var addcard = $("#addcard").find("option:selected").val();
					var aliprofitratio = $("#aliprofitratio").val();
					var regimoney = $("#regimoney").val();
					var regishopmoney = $("#regishopmoney").val();
					var regitime = $("#regitime").val();
					var sqappkey = $("#sqappkey").val();
					var overdraft = $("#overdraft").val();
					var signid = $("#signid").val();
					var count = $("#count").val();
					var jhappid = $("#jhappid").val();
					var jhappkey = $("#jhappkey").val();
					var ajax = ajaxObject();
					if (username == "" || username == null) {
						alert("账号名不能为空");
					} else if (password == "" || password == null) {
						alert("密码不能为空");
					} else {
						ajax.open("post", "insertShop?password=" + password +
							"&pic=" + pic +
							"&jhappid=" + jhappid +
							"&jhappkey=" + jhappkey +
							"&username=" + username +
							"&adid=" + adid +
							"&pid=" + pid +
							"&email=" + email +
							"&calltype=" + calltype +
							"&isalipay=" + isalipay +
							"&airrecharge=" + airrecharge +
							"&role=" + 1 +
							"&freeroute=" + freeroute +
							"&nextagent=" + nextagent +
							"&isprofit=" + isprofit +
							"&aliprofitratio=" + aliprofitratio +
							"&dkbl=" + dkbl +
							"&agentlogo=" + logo +
							"&addcard=" + addcard +
							"&sqappkey= " + sqappkey +
							"&regimoney=" + regimoney +
							"&regishopmoney=" + regishopmoney +
							"&regitime=" + regitime +
							"&overdraft=" + overdraft +
							"&isaliprofit=" + isaliprofit +
							"&signid=" + signid +
							"&count="+ count, true);
						ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
						ajax.onreadystatechange = function() {
							if (ajax.readyState == 4) {
								if (ajax.status == 200) {
									var result = ajax.responseText;
									if (result == "success") {
										//请求成功
										alert("创建成功");
										location.href = "content_oemguanli";
									} else {
										//创建失败
										alert(result);
									}
								} else {
									//请求失败
									alert("请求终止，请检查操作或联系客服咨询" + ajax.status);
								}
							} else {
							}
						};
						ajax.send();
					}
				}
			</script>
		</div>
	</div>


	<!-- jQuery -->
	<script src="<%=basePath%>vendors/jquery/dist/jquery.min.js"></script>
	<!-- Bootstrap -->
	<script src="<%=basePath%>vendors/bootstrap/dist/js/bootstrap.min.js"></script>
	<!-- FastClick -->
	<script src="<%=basePath%>vendors/fastclick/lib/fastclick.js"></script>
	<!-- NProgress -->
	<script src="<%=basePath%>vendors/nprogress/nprogress.js"></script>
	<!-- bootstrap-daterangepicker -->
	<script src="<%=basePath%>vendors/moment/min/moment.min.js"></script>
	<script
		src="<%=basePath%>vendors/bootstrap-daterangepicker/daterangepicker.js"></script>
	<!-- Chart.js -->
	<script src="<%=basePath%>vendors/Chart.js/dist/Chart.min.js"></script>
	<!-- validator -->
	<script src="<%=basePath%>vendors/validator/validator.js"></script>
	<!-- Custom Theme Scripts -->
	<script src="<%=basePath%>build/js/custom.min.js"></script>
	<!-- Select2 -->
	<script src="<%=basePath%>vendors/select2/dist/js/select2.full.min.js"></script>
</body>
</html>